using System;
using System.Collections.Generic;

using GarageGames.Torque.Core;
using GarageGames.Torque.SceneGraph;
using GarageGames.Torque.Sim;
using GarageGames.Torque.GameUtil;
using GarageGames.Torque.Platform;
using GarageGames.Torque.GUI;
using GarageGames.Torque.T3D;

using Microsoft.Xna.Framework;
using TimeWar;

namespace StarterGame3D
{
    /// <summary>
    /// This is the main game class for your game
    /// </summary>
    public class Game : TorqueGame
    {
        //======================================================
        #region Static methods, fields, constructors

        /// <summary>
        /// A static property that lets you easily get the Game instance from any Game class.
        /// </summary>
        public static Game Instance
        {
            get { return _myGame; }
        }

        #endregion

        //======================================================
        #region Public Methods

        public static void Main()
        {
            // Create the static game instance.  
            _myGame = new Game();

            // begin the game.  Further setup is done in BeginRun()
            _myGame.Run();
        }

        #endregion

        //======================================================
        #region Private, protected, internal methods

        /// <summary>
        /// Called after the graphics device is created and before the game is about to start running.
        /// </summary>
        protected override void BeginRun()
        {
            base.BeginRun();

            // load our scene objects from XML.  Torque X is designed to load game data from XML, but this is not strictly required;
            // anything in an XML file can also be created manually in C# code.  The SceneLoader is provided by TorqueGame and can be
            // used to load and unload XML files.
            SceneLoader.Load(@"data\levels\levelData.txscene");

            // all 3D scene views must have a camera set
            GUISceneview sceneView = TorqueObjectDatabase.Instance.FindObject<GUISceneview>("DefaultSceneView");
            FreeCameraComponent camera = TorqueObjectDatabase.Instance.FindObject<FreeCameraComponent>("CameraComponent");
            sceneView.Camera = camera;

            if (timeWarGame == null)
            {
                timeWarGame = new TimeWarGame();
            }

            timeWarGame.BeginRun();
        }

        #endregion

        //======================================================
        #region Private, protected, internal fields

        static Game _myGame;
        private TimeWarGame timeWarGame = null;

        #endregion
    }
}